// 判断是否需要显示金蛋
jQuery(function () {

    if (window.localStorage && localStorage['hide_golden_egg']) return;

    jQuery.ajax({
        type: 'get',
        url: '/active/showLottery.do',
        dataType: 'json',
        success: function (result) {
            var resultCode = result.result;
            // 显示抽奖入口
            if (resultCode >= 0 || resultCode == -8) {
                showGoldenEgg();
            }
        }
    })
});

// 侧边显示金蛋
function showGoldenEgg() {
    var imgUrl = window.preUrlForEgg + '/image/active/goldEgg/float-egg.gif';
    var eggStyle = 'position:fixed;bottom:60px;right:20px;width:120px;';
    var closeStyle = 'position:absolute;top:0;right:-10px;font-size:20px;cursor:pointer;';
    var forwardUrl = window.forwardUrlForEgg || '/about/goldEgg.do';
    jQuery(document.body).append('<div id="goldEggEntrance" style="' + eggStyle + '"><span style="' + closeStyle + '" onclick="hideGoldenEgg()">&times;</span><a href="' + forwardUrl + '" target="_blank"><img src="' + imgUrl + '" style="width:100%"/></a></div>');
}

// 隐藏不再显示
function hideGoldenEgg() {
    jQuery('#goldEggEntrance').remove();
    if (window.localStorage) {
        localStorage['hide_golden_egg'] = true;
    }
}